;
(function (window, angular) {
    'use strict';
    angular.module("Controller.Report.Indicator", [])
        .controller("IndicatorCtrl", ["$scope", "$state", "ybWidget", "ybHttp", "MESG_TYPE", "$filter", "$timeout", "UserContextService", function ($scope, $state, ybWidget, ybHttp, MESG_TYPE, $filter, $timeout, UserContextService) {
            $scope.datePickerFlag = [false, false];
            $scope.condition = { reportType: 1 };
            $scope.dataList = [];

            $scope.switchDataPicker = function (index) {
                $scope.datePickerFlag = [false, false];
                if (angular.isDefined(index)) {
                    $scope.datePickerFlag[index] = true;
                }
            };

            $scope.checkDate = function (obj, startFiled, endFiled) {
                var timeFormatObj = ybWidget.CheckDate(obj[startFiled], obj[endFiled]);
                if (!timeFormatObj) {
                    return;
                }
                if (!!timeFormatObj.tStart) {
                    obj[startFiled] = timeFormatObj.tStart;
                }
                if (!!timeFormatObj.tEnd) {
                    obj[endFiled] = timeFormatObj.tEnd;
                }
            };
            //xbt     
            $scope.componyList = [];
            
            function getCompanyList(curPage) {
                var service = "device";
                var reqUrl = "/company/listCoreComs"; 
                //空对象返回所有主机厂              
                ybHttp.Post(service, reqUrl,{}).then(function (resp) {
                    if (resp.code !== 0) {
                        ybWidget.ShowMessage(resp, MESG_TYPE.Error);
                        return;
                    }
                    $scope.companyList = resp.value;
                });
            }
            //xbt
            function getDataList(curPage) {
                var service = "device";
                var reqUrl = "/report/indicatorReport";
                var param = angular.copy($scope.condition);
                ybHttp.Post(service, reqUrl, param).then(function (resp) {
                    if (resp.code !== 0) {
                        ybWidget.ShowMessage(resp, MESG_TYPE.Error);
                        return;
                    }
                    $scope.dataList = resp.value;
                });
            }

            $scope.search = function (curpage) {
                getDataList(curpage);
            };

            (function () {
                getDataList();
                getCompanyList();
            })();
        }])
        ;
})(window, window.angular);